<template>
    <div class="feedback">
        <!-- 意见反馈 -->
        <van-nav-bar title="意见反馈" left-arrow @click-left="onClickLeft" />
        <div class="content">
            <van-form>
                <van-cell-group :border="false" title="问题描述">
                    <van-field v-model="message" rows="2" autosize type="textarea" maxlength="500"
                        placeholder="请输入问题或建议" show-word-limit />
                </van-cell-group>
            </van-form>
            <van-button type="primary" @click="onSubmit">提交</van-button>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { Toast } from 'vant';
import { fetchSuggest } from '../../../api/index';
const message = ref(""); 
let formData = new FormData();
// 定义onClickLeft方法
const onClickLeft = () => history.back();
const onSubmit = () => {
    formData.append("content", message.value)
    fetchSuggest(formData).then(res => {
        // console.log(res)
        if (res.code == 1) {
            Toast(res.msg)
            let timer=setTimeout(() => {
                clearTimeout(timer);
                history.back();
            }, 1000);
        } else {
            Toast(res.msg)
        }
    })
    formData = new FormData();
};


</script>

<style lang="less" scoped>
@import url(../../../style/common.css);
.feedback {
    background: #FFFFFF;
    width: 100%;
    height: 100vh;
}

.van-nav-bar {
    width: 100%;
    height: 52px;
}

.content {
    .van-cell {
        margin: 0 20px;
        text-align: left;
        width: 345px;
        min-height: 125px;
        height: 100%;
        background: #F9F9F9;
        border-radius: 9px 9px 9px 9px;
        display: flex;
        box-sizing: border-box;

        .van-field {
            margin: 0;
            padding: 0;
            background: #F7F7F7;
            border-radius: 6px 6px 6px 6px;
        }
    }



    .van-button {
        margin-top: 24px;
        width: 345px;
        height: 40px;
        background: linear-gradient(143deg, #0A84FF 0%, #0A7EF3 100%);
        border-radius: 347px 347px 347px 347px;
    }
}



:deep(.van-nav-bar__left .van-badge__wrapper) {
    color: #272635;
}

:deep(.content .van-cell-group__title) {
    text-align: left;
}
</style>